The starting point for hydrograph analysis is to obtain the source data. Let’s see how it goes with sample spas-zagorye.txt discharge data for \(1956-2020\) year range provided with grwat. This data is for Spas-Zagorye gauge on Protva river in Central European plane:
library(sf) # reading and manipulating spatial data
library(tidyverse) # general data wrangling
library(mapview) # interactive mapping of spatial data
library(ecmwfr) # this is to access ERA5 reanalysis data
library(grwat)
mapviewOptions(fgb = FALSE)
# this is path to sample data installed with grwat
path = system.file("extdata", "spas-zagorye.txt", package = "grwat")
# for your own data just provide the full path:
# path = /this/is/the/path/to/discharge/discharge.csv
hdata_raw = read_delim(path,
col_names = c('d', 'm', 'y', 'q'),
col_types = 'iiid', delim = ' ') # read gauge data
head(hdata_raw) # see the data
#> # A tibble: 6 x 4
#> d m y q
#> <int> <int> <int> <dbl>
#> 1 1 1 1956 5.18
#> 2 2 1 1956 5.18
#> 3 3 1 1956 5.44
#> 4 4 1 1956 5.44
#> 5 5 1 1956 5.44
#> 6 6 1 1956 5.58grwat expects the date as a single column. Therefore, in this case we have to construct it manually. For this it is convenient to use make_date() function from lubridate package:
hdata = hdata_raw %>%
transmute(Date = lubridate::make_date(y, m, d),
Q = q)
head(hdata)
#> # A tibble: 6 x 2
#> Date Q
#> <date> <dbl>
#> 1 1956-01-01 5.18
#> 2 1956-01-02 5.18
#> 3 1956-01-03 5.44
#> 4 1956-01-04 5.44
#> 5 1956-01-05 5.44
#> 6 1956-01-06 5.58The basic data structure for grwat separation function is a data frame (or tibble) with two columns: date (first column) and discharge (second column). The columns can have any names, not necessarily
DandQ.
Hydrograph data may contain empty values due to corrupted records or missed observations at specific dates. A short summary of gap periods can be obtained by gr_get_gaps() function:
gaps = gr_get_gaps(hdata)
gaps
#> # A tibble: 8 x 5
#> num start_date end_date duration type
#> <int> <date> <date> <drtn> <chr>
#> 1 1 1956-01-01 1970-04-09 5213 days data
#> 2 2 1970-04-10 1970-04-12 3 days gap
#> 3 3 1970-04-13 1979-09-09 3437 days data
#> 4 4 1979-09-10 1979-09-11 2 days gap
#> 5 5 1979-09-12 2011-05-09 11563 days data
#> 6 6 2011-05-10 2011-05-14 5 days gap
#> 7 7 2011-05-15 2020-12-26 3514 days data
#> 8 8 2020-12-27 2020-12-31 5 days gapgr_fill_gaps() function allows filling gaps in the data. This function first expands the date sequence if some dates are missing between the minimum and the maximum date in the table, and then trims the sequence of dates if missing obervations are at the beginning or end of the sequence. After expansion all missing observations are filled by linear interpolation between nearest values.
You can limit the maximum gap extent by threshold autocorrelation value (autocorr parameter) or expliсit number of observations (nobserv parameter):
fhdata = gr_fill_gaps(hdata, autocorr = 0.7)
#> grwat: filled 10 observations using 5 days window
fhdata = gr_fill_gaps(hdata, nobserv = 10)
#> grwat: filled 10 observations using 10 days windowHow the time window is computed in the first case? When the autocorr parameter is used, the ACF (autocorrelation function) is computed first, and then its values are used to obtain the time shift (in days) during which the autocorrelation is higher or equal to the specified value. For Spas-Zagorye data the time lag for \(ACF \geq 0.7\) is 6 days, which can be inferred by gr_plot_acf() function:
gr_plot_acf(hdata)A sole discharge data is enough to separate the hydrograph into quickflow and baseflow, but is not sufficient to predict the genesis of quickflow cases. Was it due to rain or thaw? To answer such questions you also need precipitation and temperature data. Ideally, these must be measured at the gauge. But often such data is not available. In this case you need to mine this data from external sources.
One of the ways to obtain the temperature and precipitation data is to use reanalyses such as ERA5. Reanalysis data is arranged as regular grids with specific resolution. In particular, the ERA5 data has \(31\) km or \(0.28125\) degrees resolution. To use such data you must tolerate the fact that none of the reanalysis grid nodes will coincide with your gauge. Instead, you have to use the data, which is either
The last two options are the most adequate. Let’s see how it can be done.
First, we need to read the basin spatial data:
# this is path to sample basin geopackage installed with grwat
path = system.file("extdata", "spas-zagorye.gpkg", package = "grwat")
# for your own data just provide the full path:
# path = /this/is/the/path/to/discharge/basin.shp
basin = st_read(path, layer = 'basin') # read basin region
#> Reading layer `basin' from data source
#> `/Users/tsamsonov/GitHub/grwat/inst/extdata/spas-zagorye.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 1 feature and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 35.41204 ymin: 54.88195 xmax: 36.84138 ymax: 55.57005
#> Geodetic CRS: WGS 84
gauge = st_read(path, layer = 'gauge') # read gauge point
#> Reading layer `gauge' from data source
#> `/Users/tsamsonov/GitHub/grwat/inst/extdata/spas-zagorye.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 36.62272 ymin: 55.03669 xmax: 36.62272 ymax: 55.03669
#> Geodetic CRS: WGS 84
mapview(basin) + mapview(gauge)Next, we can buffer the data on the specified distance to catch more reanalysis data. For this we use gr_buffer_geo function, which approximates geographic buffer of the specified radius:
basin_buffer = gr_buffer_geo(basin, 25000)
mapview(basin_buffer, col.regions = 'red') +
mapview(basin)Alternatively you can just buffer the gauge point, though it is less meaningful since you will grab reanalysis data that falls out of gauge’s basin:
gauge_buffer = gr_buffer_geo(gauge, 50000)
mapview(gauge_buffer, col.regions = 'red') +
mapview(gauge)grwat is packaged with daily reanalysis which covers the East European territory of Russia. It has a spatial resolution of \(0.75^{\circ} \times 0.75^{\circ}\), and temporal resolution of \(1\) (one) day. Data sources include:
The coverage of the reanalysis is shown below:
The reanalysis consists of two data files, each file is about 850 Mb in size:
Download this data using the FTP link for using with grwat.
rean = gr_read_rean('/Volumes/Data/Spatial/Reanalysis/grwat/pre_1880-2021.nc',
'/Volumes/Data/Spatial/Reanalysis/grwat/temp_1880-2021.nc') # read reanalysis data
fhdata_rean = gr_join_rean(fhdata, rean, basin_buffer) # join reanalysis data to hydrological series
#> Joining, by = "Date"
head(fhdata_rean)
#> # A tibble: 6 x 4
#> Date Q Temp Prec
#> <date> <dbl> <dbl> <dbl>
#> 1 1956-01-01 5.18 -6.46 0.453
#> 2 1956-01-02 5.18 -11.4 0.825
#> 3 1956-01-03 5.44 -10.7 0.26
#> 4 1956-01-04 5.44 -8.05 0.397
#> 5 1956-01-05 5.44 -11.7 0.102
#> 6 1956-01-06 5.58 -20.1 0.032After reanalysis data are joined you can easily plot a map of the derived spatial configuration:
# plot spatial configuration
m = mapview(basin_buffer, col.regions = 'red') +
mapview(basin) +
mapview(rean$pts[basin_buffer, ], col.regions = 'black') +
mapview(rean$pts, cex = 1)
box = st_bbox(basin_buffer)
center = st_coordinates(st_centroid(basin_buffer))
#> Warning in st_centroid.sf(basin_buffer): st_centroid assumes attributes are
#> constant over geometries of x
m@map %>% leaflet::setView(center[1], center[2], zoom = 7)To be described
The basic separation procedure is provided by get_baseflow() function. One of the most commonly used approaches is the method by Lyne-Hollick (1979):
resbase = fhdata %>%
mutate(Qbase = gr_baseflow(Q, method = 'lynehollick'))
# quick look at the table
head(resbase, 10)
#> # A tibble: 10 x 3
#> Date Q Qbase
#> <date> <dbl> <dbl>
#> 1 1956-01-01 5.18 3.70
#> 2 1956-01-02 5.18 3.79
#> 3 1956-01-03 5.44 3.88
#> 4 1956-01-04 5.44 3.96
#> 5 1956-01-05 5.44 4.04
#> 6 1956-01-06 5.58 4.11
#> 7 1956-01-07 5.58 4.19
#> 8 1956-01-08 5.36 4.25
#> 9 1956-01-09 5.36 4.32
#> 10 1956-01-10 5.31 4.38
resbase %>%
filter(lubridate::year(Date) == 2020) %>%
ggplot() +
geom_area(aes(Date, Q), fill = 'steelblue', color = 'black') +
geom_area(aes(Date, Qbase), fill = 'orangered', color = 'black')The separation is mainly parameterized by smoothing parameter which is a = 0.925 by default, and number of passes, which are passes = 3 by default. Changing them affects the shape of a baseflow component:
resbase = fhdata %>%
mutate(Qbase = gr_baseflow(Q, method = 'lynehollick', a = 0.8, passes = 5))
resbase %>%
filter(lubridate::year(Date) == 2020) %>%
ggplot() +
geom_area(aes(Date, Q), fill = 'steelblue', color = 'black') +
geom_area(aes(Date, Qbase), fill = 'orangered', color = 'black')Let’s see how different separation methods act in comparison to each other:
methods = c("maxwell",
"boughton",
"jakeman",
"lynehollick",
"chapman")
plots = lapply(methods, function(m) {
resbase = fhdata %>%
mutate(Qbase = gr_baseflow(Q, method = m))
resbase %>%
filter(lubridate::year(Date) == 2020) %>%
ggplot() +
geom_area(aes(Date, Q), fill = 'steelblue', color = 'black') +
geom_area(aes(Date, Qbase), fill = 'orangered', color = 'black') +
labs(title = m)
})
patchwork::wrap_plots(plots, ncol = 2)Advanced separation aims at revealing the genesis of the quickflow. Was it due to a rain or snowmelting? For this, a joint analysis of discharge, temperature and precipitation time series is performed by specialized algorithm, available from gr_separate() function in grwat package.
The genetic separation of hydrograph is controlled by more than 30 parameters. The names and meaning of these paramters can be learned thanks to gr_help_params() function:
gr_help_params()
#> # A tibble: 31 x 11
#> number name example desc units formula comments pics desc_rus role_1
#> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <lgl> <chr> <chr>
#> 1 1 mome 11 the fi… <NA> <NA> "not used… NA месяц, с… <NA>
#> 2 2 grad 1.5 rate o… %/day <NA> "if chang… NA интенсив… separ…
#> 3 3 grad1 2 rate o… %/day "\"\"" "\"\"" NA интенсив… <NA>
#> 4 4 kdQgr1 150 maximu… % <NA> "can be d… NA максимал… <NA>
#> 5 5 polmo… 2 the ea… <NA> <NA> "can be d… NA cамый ра… <NA>
#> 6 6 polmo… 5 the la… <NA> <NA> "can be d… NA самый по… <NA>
#> 7 7 polko… 15 amount… <NA> <NA> <NA> NA количест… <NA>
#> 8 8 polko… 25 amount… days <NA> <NA> NA количест… <NA>
#> 9 9 polko… 30 amount… days <NA> "can be d… NA количест… <NA>
#> 10 10 polgr… 10 mean r… % <NA> <NA> NA значения… <NA>
#> # … with 21 more rows, and 1 more variable: role_2 <chr>Since the number of parameters is large (31), they are organized as list, which is then fed into gr_separate() function. First, you get the params using the gr_get_params() function. The only parameter of the function is reg, which indicates the region for which the parameters must be extracted. After you got the parameters, they can be changed by accessing the list elements:
# Расчленение
p = gr_get_params(reg = 'Midplain')
p$nPav = 5
p$prodspada = 85Next, you can separate the hydrograph:
sep = gr_separate(fhdata_rean, p, alpha = 0.85)
head(sep)
#> # A tibble: 6 x 11
#> Date Q Qbase Quick Qseas Qrain Qthaw Qpb Qtype Temp Prec
#> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl>
#> 1 1956-01-01 5.18 5.18 0 0 0 0 0 0 -6.46 0.453
#> 2 1956-01-02 5.18 5.18 0 0 0 0 0 0 -11.4 0.825
#> 3 1956-01-03 5.44 5.44 0 0 0 0 0 0 -10.7 0.26
#> 4 1956-01-04 5.44 5.44 0 0 0 0 0 0 -8.05 0.397
#> 5 1956-01-05 5.44 5.44 0 0 0 0 0 0 -11.7 0.102
#> 6 1956-01-06 5.58 5.58 0 0 0 0 0 0 -20.1 0.032After the hydrograph is separated, it can be summarized in a set of variables:
vars = gr_summarize(sep)
head(vars)
#> # A tibble: 6 x 57
#> Year Year1 Year2 datestart datepolend PolProd Qy Qmax datemax Qygr
#> <int> <int> <dbl> <date> <date> <int> <dbl> <dbl> <date> <dbl>
#> 1 1956 1956 1957 1956-04-08 1956-05-02 24 18.3 467 1956-04-22 9.57
#> 2 1957 1957 1958 1957-03-31 1957-05-01 31 20.3 460 1957-04-08 11.6
#> 3 1958 1958 1959 1958-04-06 1958-05-06 30 27.4 537 1958-04-21 13.1
#> 4 1959 1959 1960 1959-03-31 1959-04-27 27 27.1 406 1959-04-16 12.8
#> 5 1960 1960 1961 1960-03-30 1960-04-26 27 29.5 406 1960-04-15 14.4
#> 6 1961 1961 1962 1961-03-12 1961-04-14 33 18.7 296 1961-04-10 13.8
#> # … with 47 more variables: Qmmsummer <dbl>, monmmsummer <date>, Qmmwin <dbl>,
#> # nommwin <date>, Q30s <dbl>, date30s1 <date>, date30s2 <date>, Q30w <dbl>,
#> # date30w1 <date>, date30w2 <date>, Q10s <dbl>, date10s1 <date>,
#> # date10s2 <date>, Q10w <dbl>, date10w1 <date>, date10w2 <date>, Q5s <dbl>,
#> # date5s1 <date>, date5s2 <date>, Q5w <dbl>, date5w1 <date>, date5w2 <date>,
#> # Wy <dbl>, Wgr <dbl>, Wpol2 <dbl>, Wpol1 <dbl>, Wpol3 <dbl>, Wpavs2 <dbl>,
#> # Wpavs1 <dbl>, Wpavthaw2 <dbl>, Wpavthaw1 <dbl>, WgrS <dbl>, WS <dbl>,
#> # WgrW <dbl>, WW <dbl>, Qmaxpavs <dbl>, Qmaxpavthaw <dbl>,
#> # datemaxpavs <date>, datemaxpavthaw <date>, SumProd <int>,
#> # DaysPavsSum <int>, WinProd <int>, DaysThawWin <int>, CvWin <dbl>,
#> # CvSum <dbl>, CountPavs <int>, CountThaws <int>These functions from grwat package allow you to:
Graphical functions are based on ggplot2 graphics.
You can plot separations for selected years using gr_plot_sep() function:
gr_plot_sep(sep, 1976) # plot single yeargr_plot_sep(sep, c(2016, 2017)) # plot two years sequentiallysep %>%
filter(lubridate::year(Date) == 1976) %>%
ggplot() +
geom_area(aes(Date, Q), fill = 'steelblue', color = 'black') +
geom_area(aes(Date, Qbase), fill = 'orangered', color = 'black')And also multiple years on the same layout:
gr_plot_sep(sep, 1976:1979, # plot four years on the same page
layout = matrix(c(1,2,3,4), ncol=2, byrow = T))
#> Warning: Removed 36 rows containing missing values (position_stack).To get the detailed description of available variables you can invoke gr_help_vars():
gr_help_vars()
#> # A tibble: 57 x 19
#> ID Position Width Source Name Units Unitsen Readtype Type Test Desc
#> <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <dbl> <chr>
#> 1 1 1 7 1 year_… <NA> <NA> integer inte… 0 Номер …
#> 2 2 8 10 1 Year1 Год Year integer inte… 0 Год, к…
#> 3 3 18 10 1 Year2 Год Year integer inte… 0 Год, к…
#> 4 4 28 15 1 dates… Дата Date Date Date 1 Дата н…
#> 5 5 43 15 1 datep… Дата Date Date Date 1 Дата о…
#> 6 57 0 0 0 PolPr… Дней Days integer inte… 1 Продол…
#> 7 6 58 10 1 Qy м^3/с m^3/s double doub… 1 Средни…
#> 8 7 68 10 1 Qmax м^3/с m^3/s double doub… 1 Максим…
#> 9 8 78 15 1 datem… Дата Date Date Date 1 Дата м…
#> 10 9 93 10 1 Qygr м^3/с m^3/s double doub… 1 Средни…
#> # … with 47 more rows, and 8 more variables: Descen <chr>, Group <chr>,
#> # Winter <dbl>, Chart <chr>, Color <chr>, Order <dbl>, Range <chr>,
#> # Problems <chr>Parameters can be statistically tested using test_variables(df, ..., year = NULL, locale='EN') function. Names of the parameters are passed comma-separated in place of .... They are quoted, so you do not need to pass them as character strings, just write their names:
gr_test_vars(vars, Qmax)
#> Warning: `select_()` was deprecated in dplyr 0.7.0.
#> Please use `select()` instead.
#> $ptt
#> $ptt$Qmax
#>
#> Pettitt's test for single change-point detection
#>
#> data: vl[vl_cmp]
#> U* = 481, p-value = 0.01088
#> alternative hypothesis: two.sided
#> sample estimates:
#> probable change point at time K
#> 15
#>
#>
#>
#> $mkt
#> $mkt$Qmax
#>
#> Mann-Kendall trend test
#>
#> data: vl[vl_cmp]
#> z = -3.4302, n = 64, p-value = 0.0006031
#> alternative hypothesis: true S is not equal to 0
#> sample estimates:
#> S varS tau
#> -593.0000000 29785.0000000 -0.2946588
#>
#>
#>
#> $tst
#> $tst$Qmax
#>
#> Sen's slope
#>
#> data: df.theil[[2]][fltr]
#> z = -3.4302, n = 64, p-value = 0.0006031
#> alternative hypothesis: true z is not equal to 0
#> 95 percent confidence interval:
#> -5.509091 -1.578947
#> sample estimates:
#> Sen's slope
#> -3.673571
#>
#>
#>
#> $ts_fit
#> $ts_fit$Qmax
#>
#> Call:
#> mblm::mblm(formula = eval(frml), dataframe = df.theil[fltr, ],
#> repeated = FALSE)
#>
#> Coefficients:
#> (Intercept) Year1
#> 7559.226 -3.674
#>
#>
#>
#> $tt
#> $tt$Qmax
#>
#> Welch Two Sample t-test
#>
#> data: d1 and d2
#> t = 3.6895, df = 19.259, p-value = 0.001528
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> 77.05147 278.65996
#> sample estimates:
#> mean of x mean of y
#> 419.7857 241.9300
#>
#>
#>
#> $ft
#> $ft$Qmax
#>
#> F test to compare two variances
#>
#> data: d1 and d2
#> F = 1.2427, num df = 13, denom df = 49, p-value = 0.5594
#> alternative hypothesis: true ratio of variances is not equal to 1
#> 95 percent confidence interval:
#> 0.5696173 3.4140498
#> sample estimates:
#> ratio of variances
#> 1.242725
#>
#>
#>
#> $year
#> Qmax
#> 1970
#>
#> $maxval
#> $maxval$Qmax
#> [1] 780
#>
#>
#> $fixed_year
#> [1] FALSE
#>
#> $pvalues
#> N Variable Change.Year Trend
#> 1 1 Maximum annual discharge during seasonal flood wave 1970 -3.67357
#> M1 M2 MeanRatio sd1 sd2 sdRatio Mann.Kendall Pettitt
#> 1 419.7857 241.93 -42.4 162.9446 146.1681 -10.3 6e-04 0.01088
#> Student Fisher
#> 1 0.00153 0.55942This is an example with three variables selected:
tests = gr_test_vars(vars, Qygr, date10w1, Wpol3)
tests$pvalues
#> N Variable
#> 1 1 Annual groundwater discharge ("baseflow") during water-resources year
#> 2 2 First date of 10-day window discharge during winter
#> 3 3 Seasonal flood runoff (with groundwater and rainwater)
#> Change.Year Trend M1 M2 MeanRatio sd1 sd2 sdRatio
#> 1 1977 0.09002 11.10477 16.17136 45.6 2.70576 3.26140 20.5
#> 2 1987 -0.33333 25-Jan 10-Jan -15.0 33.00000 40.00000 21.2
#> 3 1989 -0.10095 10.26801 6.71493 -34.6 5.39415 3.95534 -26.7
#> Mann.Kendall Pettitt Student Fisher
#> 1 0.00054 0.00001 0.00000 0.37063
#> 2 0.24173 0.60713 0.11401 0.27717
#> 3 0.00111 0.01900 0.00414 0.09273If you want to test all parameters, just skip variable names:
tests = gr_test_vars(vars)
tests$year # this is a change year detected for each variable
#> Wy Wpol2 Wgr Wpol1 Wpavs2
#> 1978 1974 1977 1974 1975
#> Wpavs1 Wpavthaw2 Wpavthaw1 WgrW WW
#> 1975 1983 1975 1978 1978
#> WgrS WS Qy datestart Qygr
#> 1977 1977 1978 1970 1977
#> datepolend PolProd Qmax datemax Wpol3
#> 1987 1987 1970 1970 1989
#> Qmmwin nommwin Qmmsummer monmmsummer Q30w
#> 1979 2004 1979 2000 1979
#> date30w1 Q30s date30s1 Q10w date10w1
#> 1995 1979 2000 1979 1987
#> Q10s date10s1 Q5w date5w1 Q5s
#> 1981 2000 1979 1965 1981
#> date5s1 Qmaxpavthaw datemaxpavthaw CountThaws DaysThawWin
#> 2000 2013 1995 1995 1984
#> Qmaxpavs datemaxpavs CountPavs DaysPavsSum CvWin
#> 1960 1999 1980 1968 1983
#> WinProd CvSum SumProd
#> 1968 1983 1999Long-term changes are tested against breaking year, which is calculated for each variable using Pettitt test. However, if you want to use a fixed year, you should pass the desired breaking year into change_year parameter:
tests = gr_test_vars(vars, Qmax, Qygr, change_year = 1987)
tests$ft # Fisher F tests to compare two variances
#> $Qmax
#>
#> F test to compare two variances
#>
#> data: d1 and d2
#> F = 1.2427, num df = 13, denom df = 49, p-value = 0.5594
#> alternative hypothesis: true ratio of variances is not equal to 1
#> 95 percent confidence interval:
#> 0.5696173 3.4140498
#> sample estimates:
#> ratio of variances
#> 1.242725
#>
#>
#> $Qygr
#>
#> F test to compare two variances
#>
#> data: d1 and d2
#> F = 0.68829, num df = 20, denom df = 42, p-value = 0.3706
#> alternative hypothesis: true ratio of variances is not equal to 1
#> 95 percent confidence interval:
#> 0.3357736 1.5681701
#> sample estimates:
#> ratio of variances
#> 0.6882895Interannual changes are visualized using gr_plot_vars() function. Its syntax is similar to gr_test_vars() and gr_plot_sep():
gr_plot_vars(vars, Qmax) # plot one selected variablegr_plot_vars(vars, datestart) # plot one selected variablegr_plot_vars(vars, date10w1, Wpol3) # plot two variables sequentially#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
gr_plot_vars(vars, Qmax, Qygr, date10w1, Wpol3, # plot four variables in matrix layout
layout = matrix(c(1,2,3,4), nrow=2, byrow=TRUE))
#> Warning: Removed 1 rows containing non-finite values (stat_smooth).You can add the results of statistical tests to the plot by specifying tests = TRUE in the function call. In that case the subtitle with test results are added, Theil-Sen slope and Pettitt test breaking year are drawn as solid (\(p \leq 0.05\)) or dashed (\(p > 0.05\)) lines:
gr_plot_vars(vars, date10w1, Wpol3, DaysThawWin, Qmaxpavs,
tests = TRUE) # add test information#> Warning: Removed 1 rows containing non-finite values (stat_smooth).
Alternatively, you can pass to tests the result of test_variables(), if you need to precompute it with specific parameters (for example, by setting exclude and year:
gr_plot_vars(vars, date10w1, Wpol3, DaysThawWin, Qmaxpavs,
tests = gr_test_vars(vars, date10w1, Wpol3, DaysThawWin, Qmaxpavs, exclude = 1990)) # add test informationBeware that in that case you should test the variables in the same order as used for plotting. If you plot variables A, B, C and supply tests for variables X, Y, Z, they will be added without any warnings, and it is your responsibility to keep them in correspondence with each other.
Finally, you can plot all variables by not supplying column names to plot_variables() function. In that case tests (if you want to plot them too) should also be calculated for all variables:
gr_plot_vars(vars, tests = TRUE)Long-term changes are the differences between summarized statistics of one variable calculated for two selected periods. Because these statistics reflect the differences in distributions of parameters, grwat visualizes them as box plots using gr_plot_periods() function. The syntax is similar to gr_plot_vars() except that you must provide either tests or year parameter. If both are supplied then tests is prioritized (you can also supply a fixed year when testing variables:
gr_plot_periods(vars, Qy, year = 1978)gr_plot_periods(vars, Qy, tests = TRUE)gr_plot_periods(vars, Qy, tests = gr_test_vars(vars, Qy, year = 1985))Multiple plots can be combined on one page using layout parameter:
gr_plot_periods(vars, Qy, Qmax,
tests = TRUE,
layout = matrix(c(1,2)))To plot long-term changes for all variables just skip variable names in function call:
gr_plot_periods(vars, tests = TRUE)There is also a small helper function that plots a histogram of minimal discharge month for summer and winter periods:
gr_plot_minmonth(vars, year = 1985)To render HTML report just pass separation and variables to gr_report() function, and provide the output file name:
report = paste(getwd(), 'Spas-Zagorye.html', sep = '/')
gr_report(sep, vars, output = report)
browseURL(report)See report generated by this command.